Skip to main content

LocalPlayer Properties

The Player class represents the player character in the game. It inherits all properties and methods from the Unit class, providing additional player-specific functionality.

info

The Player class extends the Unit class, which means all methods available to Unit objects are also available to Player objects.

Player-Specific Methods​

These methods are unique to the Player class and provide information about the player's inventory, enchants, and other player-specific attributes.

These methods allow you to query the player's current instance status and type.

instanceType()​

Returns the type of instance the player is currently in.

local instanceType = player:instanceType()
print("Current instance type:", instanceType)

Returns: "none" | "pvp" | "arena" | "party" | "raid" | string

note

The return value can be one of the predefined types or a string for unknown instance types.

inpvp()​

Checks if the player is in a PvP instance (battleground).

if player:inpvp() then
print("Player is in a battleground")
else
print("Player is not in a battleground")
end

inarena()​

Checks if the player is in an arena instance.

if player:inarena() then
print("Player is in an arena")
else
print("Player is not in an arena")
end

ininstance()​

Checks if the player is in a party instance (5-man dungeon).

if player:ininstance() then
print("Player is in a 5-man dungeon")
else
print("Player is not in a 5-man dungeon")
end

inraid()​

Checks if the player is in a raid instance.

if player:inraid() then
print("Player is in a raid instance")
else
print("Player is not in a raid instance")
end

Usage Examples​

Here are some examples of how you might use these methods in your addon:

local player = LT.Player
if player:inpvp() or player:inarena() then
-- Use PvP-specific logic
elseif player:ininstance() then
-- Use dungeon-specific logic
elseif player:inraid() then
-- Use raid-specific logic
else
-- Use open-world logic
end

freebagslots()​

Returns the number of free slots in the player's normal bags.

local freeSlots = player:freebagslots()
print("Free bag slots:", freeSlots)

hasmainhandenchant()​

Checks if the player's main hand weapon has an enchant.

if player:hasmainhandenchant() then
print("Main hand is enchanted")
else
print("Main hand needs enchanting")
end

mainhandenchantcharges()​

Returns the number of charges left on the player's main hand weapon enchant.

local charges = player:mainhandenchantcharges()
print("Main hand enchant charges:", charges)
note

Some enchants have charges that are consumed on use. This method helps track those charges.

mainhandenchantremaining()​

Returns the remaining time (in seconds) of the player's main hand weapon enchant.

local timeLeft = player:mainhandenchantremaining()
print("Main hand enchant time remaining:", timeLeft, "seconds")

hasoffhandenchant()​

Checks if the player's off-hand weapon has an enchant.

if player:hasoffhandenchant() then
print("Off-hand is enchanted")
else
print("Off-hand needs enchanting")
end

offhandenchantcharges()​

Returns the number of charges left on the player's off-hand weapon enchant.

local charges = player:offhandenchantcharges()
print("Off-hand enchant charges:", charges)

offhandenchantremaining()​

Returns the remaining time (in seconds) of the player's off-hand weapon enchant.

local timeLeft = player:offhandenchantremaining()
print("Off-hand enchant time remaining:", timeLeft, "seconds")

mainhandenchantid()​

Returns the enchant ID of the player's main hand weapon enchant.

local enchantID = player:mainhandenchantid()
print("Main hand enchant ID:", enchantID)

offhandenchantid()​

Returns the enchant ID of the player's off-hand weapon enchant.

local enchantID = player:offhandenchantid()
print("Off-hand enchant ID:", enchantID)

setfacing(unit)​

The Player:setfacing function adjusts the player's facing direction to face an enemy based on the enemy's position.

local target = LT.Target
Player:setfacing(target)

spec()​

Returns the Players Specialisation from 1-4

print(player:spec())

gcd()​

Returns the Players GCD

print(player:gcd())

Remember that in addition to these player-specific methods, you can also use all the methods inherited from the Unit class, such as health(), position(), aura(), and many more.